const Login = () => import("@/pages/Login");
const Home = () => import("@/pages/Home");
const Register = () => import("@/pages/Register");
const Search = () => import("@/pages/Search");
const Detail = () => import('@/pages/Detail')
const AddCartSuccess = () => import("@/pages/AddCartSuccess")
const ShopCart = () => import('@/pages/ShopCart')
const Trade = () => import('@/pages/Trade')
const Pay = () => import('@/pages/Pay')
const PaySuccess = () => import('@/pages/PaySuccess')
const Center = () => import('@/pages/Center')
export default [
    {
        path: "/",
        redirect: "/home"
    },
    {
        path: "/login",
        name: "login",
        component: Login,
        meta: { isHidden: true }
    },
    {
        path: "/register",
        name: "register",
        component: Register,
        meta: { isHidden: true },
    },
    {
        path: "/home",
        name: "home",
        component: Home
    },
    {
        path: "/search/:keyword?",
        name: "search",
        component: Search
    },
    {
        path: "/detail/:skuId",
        name: "detail",
        component: Detail
    },
    {
        path: "/addcartsuccess",
        name: "addcartsuccess",
        component: AddCartSuccess,
        beforeEnter: (to, from, next) => {
            if (from.name === 'detail') next();
            else next('/detail')
        }
    },
    {
        path: "/shopcart",
        name: "shopcart",
        component: ShopCart
    },
    {
        path: "/trade",
        name: "trade",
        component: Trade,
        beforeEnter: (to, from, next) => {
            if (from.name === 'shopcart') next();
            else next('/shopcart')
        }

    },
    {
        path: "/pay",
        name: "pay",
        component: Pay,
        beforeEnter: (to, from, next) => {
            if (from.name === 'trade') next();
            else next('/shopcart')
        }
    },
    {
        path: "/paySuccess",
        name: "paySuccess",
        component: PaySuccess,
        beforeEnter: (to, from, next) => {
            if (from.name === 'pay') next();
            else next('/shopcart')
        }
    },
    {
        path: "/center",
        // name: "center",
        component: Center,
        redirect: '/center/myorder',
        children: [
            {
                path: 'myorder',
                name: 'myOrder',
                component: () => import('@/pages/Center/components/MyOrder')
            },
            {
                path: 'teamorder',
                name: 'TeamOrder',
                component: () => import('@/pages/Center/components/TeamOrder')
            },
        ],
    },
];
